<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">  
<title>专利协同服务网络平台</title>
<link href="${pageContext.request.contextPath}/css/style.css"
	rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/select.css"
	rel="stylesheet" type="text/css" /><script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-3.2.1.min.js"></script>

<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/select-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
	$(".select").uedSelect({
		width : 120
	});
	console.log("${schoolType}");
	var options = document.getElementsByName('dicSchools');
	for(var i=0;i<options.length;i++){
		 if(options[i].value == "${schoolType}"){
			options[2].selected='selected';
   		 	break;
		 }else{
			 options[0].selected='selected';
		 }
	}
});
</script>
</head>
<body>
	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li><a href="#">首页</a></li>
			<li><a href="#">信息管理</a></li>
			<li><a href="#">单位管理员</a></li>
		</ul>
	</div>

	<div class="rightinfo">
		<form action="${pageContext.request.contextPath}${pageModel.url}"
			method="post">
			<ul class="seachform" style="margin-left: 20px; margin-top: 10px;">
				<li><label>单位</label>
					<div class="vocation">
						<select class="select" name="schoolType">
							<option name="dicSchools" value="0" selected="selected">&nbsp;全部单位</option>
							<c:forEach items="${dicSchools}" var="dicSchool">
								<option name="dicSchools" value="${dicSchool.typeCode}">&nbsp;${dicSchool.description}</option>
							</c:forEach>
						</select>
					</div></li>
				<li><label>姓名</label><input name="userName" type="text" value="${userName}"
					class="scinput" style="width: 300px;" /></li>
				<li><label>&nbsp;</label><input type="submit" class="scbtn"
					value="查询" /></li>
			</ul>
		</form>
		<div class="tools" style="margin-top: 10px;">
			<ul class="toolbar">
				<li class="click"><span><img
						src="${pageContext.request.contextPath}/images/t01.png" /></span> <a
					href="${pageContext.request.contextPath}/rootAdmin/saveUnitAdminUI.do"
					class="tablelink">添加</a></li>
			</ul>
		</div>
		<table class="tablelist">
			<thead>
				<tr>
					<th>选择</th>
					<th>姓名</th>
					<th>单位</th>
					<th>部门</th>
					<th>手机号</th>
					<th>登录密码</th>
					<th>擅长学科</th>
					<th>QQ</th>
					<th>微信</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${pageModel.list}" var="unit">
					<tr>
						<td><input name="id" type="checkbox" value="${unit.id}" /></td>
						<td>${unit.userName}</td>
						<c:forEach items="${dicSchools}" var="dicSchool">
							<c:if test="${dicSchool.typeCode == unit.schoolType}">
								<td>${dicSchool.description}</td>
							</c:if>
						</c:forEach>
						<td>${unit.department}</td>
						<td>${unit.phoneNumber}</td>
						<td>${unit.password}</td>
						<c:forEach items="${unitAdminChars}" var="unitChars">
							<c:if test="${unitChars.key == unit.id}">
								<td>${unitChars.value}</td>
							</c:if>
						</c:forEach>
						<td>${unit.QQ}</td>
						<td>${unit.weChat}</td>
						<td><a
							href="${pageContext.request.contextPath}/rootAdmin/updateUnitAdminUI.do?unitId=${unit.id}"
							class="tablelink">[修改]</a> <a
							href="javascript:deleteUnit('${unit.id}')" class="tablelink">[删除]</a></td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		<!-- 
			引入分页菜单
		-->
		<%@include file="../../common/page.jsp"%>
	</div>
	<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	function deleteUnit(unitId){
		layer.confirm('确认要删除吗？', {
			  btn: ['确认','取消'] //按钮
			}, function(){		
				window.location.href="${pageContext.request.contextPath}/rootAdmin/delUnitAdminById.do?unitId="+unitId;
				}, function(){
					
				});
		
	}
	</script>
</body>
</html>